import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
    meta:{
      isLogin:false
    }
  },
  {
    path: '/home',
    name: 'home',
    component: ()=>import('../views/Home.vue'),
    meta:{
      isLogin:true
    },
    children:[
      {
        path:'/home/student',
        name:'student',
        component:()=>import('../views/Student.vue'),
        meta:{
          isLogin:true
        },
      }
    ]
  },
]

const router = new VueRouter({
  routes
})


export default router
